Don't pass widget state flags to GtkStyleContext API
authorTimm Bäder <mail@baedert.org>
Sun, 22 Nov 2015 10:43:39 +0000 (11:43 +0100)
committerTimm Bäder <mail@baedert.org>
Sun, 22 Nov 2015 16:11:35 +0000 (17:11 +0100)
18 files changed:
gtk/gtkaboutdialog.c
gtk/gtkbindings.c
gtk/gtkcalendar.c
gtk/gtkcheckbutton.c
gtk/gtkentry.c
gtk/gtkfilechooserwidget.c
gtk/gtkflowbox.c
gtk/gtkframe.c
gtk/gtkheaderbar.c
gtk/gtkinfobar.c
gtk/gtkmenu.c
gtk/gtkpaned.c
gtk/gtkpopover.c
gtk/gtkscrolledwindow.c
gtk/gtktextutil.c
gtk/gtktextview.c
gtk/gtkviewport.c
gtk/gtkwidget.c

index 24a8ba0493fe203e802f4c1f61641e29c5a882d3..269c84051bbdd38d303d2c2aaad529d1fe276eec 100644 (file)
@@ -1919,9 +1919,13 @@ follow_if_link (GtkAboutDialog *about,
       if (uri && !g_slist_find_custom (priv->visited_links, uri, (GCompareFunc)strcmp))
         {
           GdkRGBA visited_link_color;
+          GtkStateFlags state;
           GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (about));
-          GtkStateFlags state = gtk_widget_get_state_flags (GTK_WIDGET (about));
-          gtk_style_context_get_color (context, state | GTK_STATE_FLAG_VISITED, &visited_link_color);
+          gtk_style_context_save (context);
+          state = gtk_style_context_get_state (context) | GTK_STATE_FLAG_VISITED;
+          gtk_style_context_set_state (context, state);
+          gtk_style_context_get_color (context, state, &visited_link_color);
+          gtk_style_context_restore (context);
 
           g_object_set (G_OBJECT (tag), "foreground-rgba", &visited_link_color, NULL);
 
index 2edfec0c0cd083c064ffc1cf6c6f5074c2839452..ac45da2f93fbda6be0c2880287a36463617a2a49 100644 (file)
@@ -1433,7 +1433,6 @@ gtk_bindings_activate_list (GObject  *object,
 {
   GtkStyleContext *context;
   GtkBindingSet *binding_set;
-  GtkStateFlags state;
   gboolean handled = FALSE;
   gboolean unbound = FALSE;
   GPtrArray *array;
@@ -1442,9 +1441,8 @@ gtk_bindings_activate_list (GObject  *object,
     return FALSE;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (object));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (object));
 
-  gtk_style_context_get (context, state,
+  gtk_style_context_get (context, gtk_style_context_get_state (context),
                          "-gtk-key-bindings", &array,
                          NULL);
   if (array)
index 1c735cf64d71d5d578b49c408b396ad7997dd50c..bb31f5fe1e039e2944498daa03e04642b436cd1b 100644 (file)
@@ -1086,7 +1086,7 @@ get_component_paddings (GtkCalendar *calendar,
 
   widget = GTK_WIDGET (calendar);
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   if (padding)
     gtk_style_context_get_padding (context, state, padding);
index 9e79b0b5d428d46698fb44c45ca1d3787fe62569..0b4ed9a64b9b3e19eef5d616a6b2e947c9118f97 100644 (file)
@@ -365,7 +365,7 @@ get_padding_and_border (GtkWidget *widget,
   GtkBorder tmp;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get_padding (context, state, border);
   gtk_style_context_get_border (context, state, &tmp);
index 2ac7964c9a4d330d959888f6d5ca7858652ef14f..59fa3487768782fbfac2cdaa942c8823b365dd5c 100644 (file)
@@ -3884,7 +3884,6 @@ get_progress_area (GtkWidget *widget,
   GtkStyleContext *context;
   GtkBorder border, entry_borders;
   gint frame_width, text_area_width, text_area_height;
-  GtkStateFlags state;
 
   context = gtk_widget_get_style_context (widget);
   _gtk_entry_get_borders (entry, &entry_borders);
@@ -3900,15 +3899,15 @@ get_progress_area (GtkWidget *widget,
   *width = text_area_width + entry_borders.left + entry_borders.right;
   *height = text_area_height + entry_borders.top + entry_borders.bottom;
 
-  state = gtk_style_context_get_state (context);
-
   /* if the text area got resized by a subclass, subtract the left/right
    * border width, so that the progress bar won't extend over the resized
    * text area.
    */
   if (frame_width > *width)
     {
-      gtk_style_context_get_border (context, state, &border);
+      gtk_style_context_get_border (context,
+                                    gtk_style_context_get_state (context),
+                                    &border);
       if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
         {
           *x = (frame_width - *width) + border.left;
@@ -3925,7 +3924,9 @@ get_progress_area (GtkWidget *widget,
       GtkBorder margin;
 
       gtk_style_context_save_to_node (context, private->progress_node);
-      gtk_style_context_get_margin (context, state, &margin);
+      gtk_style_context_get_margin (context,
+                                    gtk_style_context_get_state (context),
+                                    &margin);
       gtk_style_context_restore (context);
 
       *x += margin.left;
@@ -6549,7 +6550,6 @@ gtk_entry_draw_text (GtkEntry *entry,
 {
   GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
-  GtkStateFlags state = 0;
   GdkRGBA text_color;
   GdkRGBA bar_text_color = { 0 };
   GtkStyleContext *context;
@@ -6561,16 +6561,19 @@ gtk_entry_draw_text (GtkEntry *entry,
   if (gtk_entry_get_display_mode (entry) == DISPLAY_BLANK)
     return;
 
-  state = gtk_widget_get_state_flags (widget);
   context = gtk_widget_get_style_context (widget);
 
-  gtk_style_context_get_color (context, state, &text_color);
+  gtk_style_context_get_color (context,
+                               gtk_style_context_get_state (context),
+                               &text_color);
 
   /* Get foreground color for progressbars */
   if (priv->progress_node)
     {
       gtk_style_context_save_to_node (context, priv->progress_node);
-      gtk_style_context_get_color (context, state, &bar_text_color);
+      gtk_style_context_get_color (context,
+                                   gtk_style_context_get_state (context),
+                                   &bar_text_color);
       gtk_style_context_restore (context);
     }
 
@@ -6692,12 +6695,12 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
 
       if (!block_at_line_end)
         {
-          GtkStateFlags state;
           GdkRGBA color;
 
-          state = gtk_widget_get_state_flags (widget);
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          gtk_style_context_get_background_color (context, state, &color);
+          gtk_style_context_get_background_color (context,
+                                                  gtk_style_context_get_state (context),
+                                                  &color);
 G_GNUC_END_IGNORE_DEPRECATIONS
 
           gdk_cairo_rectangle (cr, &rect);
index b10dd2e68f89fad9d3376c4b2776b8713441450c..57d9d8e2f1022fdc56b69feb18aadcb10da18705 100644 (file)
@@ -6127,13 +6127,11 @@ find_good_size_from_style (GtkWidget *widget,
                            gint      *height)
 {
   GtkStyleContext *context;
-  GtkStateFlags state;
   double font_size;
   GdkScreen *screen;
   double resolution;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
   screen = gtk_widget_get_screen (widget);
   if (screen)
@@ -6145,7 +6143,10 @@ find_good_size_from_style (GtkWidget *widget,
   else
     resolution = 96.0; /* wheeee */
 
-  gtk_style_context_get (context, state, "font-size", &font_size, NULL);
+  gtk_style_context_get (context,
+                         gtk_style_context_get_state (context),
+                         "font-size", &font_size,
+                         NULL);
   font_size = font_size * resolution / 72.0 + 0.5;
 
   *width = font_size * NUM_CHARS;
index 5c42dda5168c1b56180c9bd0fe6ff849bbc66f92..d035174237d9d0199421d5d188b1c40aa89b4edb 100644 (file)
@@ -390,7 +390,7 @@ gtk_flow_box_child_draw (GtkWidget *widget,
 
   gtk_widget_get_allocation (widget, &allocation);
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height);
   gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height);
index 8909bea22c82b7c64e7d6ba0abc88b3f70151e9b..a875e58d1d649d55bc4ac11e4d955402ac9d57d6 100644 (file)
@@ -630,7 +630,7 @@ get_padding_and_border (GtkFrame *frame,
   GtkStateFlags state;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (frame));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (frame));
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get_padding (context, state, border);
 
index 4b9882ed1b4b618e7a8987e163eec1ffe591819b..da32b350a03854c480de5e50ff30ba25cddca479 100644 (file)
@@ -125,7 +125,7 @@ get_css_padding_and_border (GtkWidget *widget,
   GtkBorder tmp;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get_padding (context, state, border);
   gtk_style_context_get_border (context, state, &tmp);
index 5b11ba7c7cd677605bbb06c10b584eaa072e6502..8e421b8914c2a1032f0f8778b07cb74264e46591 100644 (file)
@@ -322,7 +322,7 @@ get_padding_and_border (GtkWidget *widget,
   GtkBorder tmp;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get_padding (context, state, border);
   gtk_style_context_get_border (context, state, &tmp);
index a3da298e55d898a021f7b950a7ca3a0dc08e97a8..771362dcd3a83d19728dbf5f64256480159e8656 100644 (file)
@@ -2594,12 +2594,12 @@ get_menu_padding (GtkWidget *widget,
                   GtkBorder *padding)
 {
   GtkStyleContext *context;
-  GtkStateFlags state;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
-  gtk_style_context_get_padding (context, state, padding);
+  gtk_style_context_get_padding (context,
+                                 gtk_style_context_get_state (context),
+                                 padding);
 }
 
 static void
@@ -2607,12 +2607,12 @@ get_menu_margin (GtkWidget *widget,
                  GtkBorder *margin)
 {
   GtkStyleContext *context;
-  GtkStateFlags state;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
-  gtk_style_context_get_margin (context, state, margin);
+  gtk_style_context_get_margin (context,
+                                gtk_style_context_get_state (context),
+                                margin);
 }
 
 static void
index 54f0c476907f3993d11cfd5a101915014ddb21bc..246d6cc34b9c5e2b1b469325be8a5cd6cfa03fc2 100644 (file)
@@ -1457,9 +1457,10 @@ gtk_paned_size_allocate (GtkWidget     *widget,
       if (gtk_widget_get_realized (widget))
        {
           GtkBorder margin;
+          GtkStyleContext *context = gtk_widget_get_style_context (widget);
 
-          gtk_style_context_get_margin (gtk_widget_get_style_context (widget),
-                                        gtk_widget_get_state_flags (widget),
+          gtk_style_context_get_margin (context,
+                                        gtk_style_context_get_state (context),
                                         &margin);
 
          if (gtk_widget_get_mapped (widget))
index 8a56db06f3f67e45df01c6c2dc8295550570d272..1df1554c23d386f983d00d85a6a4e654b08500fe 100644 (file)
@@ -648,11 +648,11 @@ get_margin (GtkWidget *widget,
             GtkBorder *border)
 {
   GtkStyleContext *context;
-  GtkStateFlags state;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
-  gtk_style_context_get_margin (context, state, border);
+  gtk_style_context_get_margin (context,
+                                gtk_style_context_get_state (context),
+                                border);
 }
 
 static void
@@ -675,7 +675,6 @@ gtk_popover_get_gap_coords (GtkPopover      *popover,
   GtkPositionType gap_side, pos;
   GtkAllocation allocation;
   gint border_radius;
-  GtkStateFlags state;
   GtkStyleContext *context;
   GtkBorder margin, border;
 
@@ -709,10 +708,9 @@ gtk_popover_get_gap_coords (GtkPopover      *popover,
   rect.y += gtk_widget_get_margin_top (widget);
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
-  gtk_style_context_get_border (context, state, &border);
-  gtk_style_context_get (context, state,
+  gtk_style_context_get (context,
+                         gtk_style_context_get_state (context),
                          GTK_STYLE_PROPERTY_BORDER_RADIUS, &border_radius,
                          NULL);
   pos = get_effective_position (popover, priv->final_position);
@@ -1064,7 +1062,7 @@ gtk_popover_draw (GtkWidget *widget,
 
   context = gtk_widget_get_style_context (widget);
 
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
   gtk_widget_get_allocation (widget, &allocation);
 
   gtk_style_context_get_border (context, state, &border);
@@ -1157,7 +1155,7 @@ get_padding_and_border (GtkWidget *widget,
   GtkBorder tmp;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
@@ -1177,7 +1175,7 @@ get_border_radius (GtkWidget *widget)
   gint border_radius;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
   gtk_style_context_get (context, state,
                          GTK_STYLE_PROPERTY_BORDER_RADIUS, &border_radius,
                          NULL);
index da37c0d4fb7407c28b0a44a4943717bf83f8640f..a85083e52ac4a9dbf686a75df5b3c4179624c279 100644 (file)
@@ -2220,7 +2220,7 @@ gtk_scrolled_window_draw_scrollbars_junction (GtkScrolledWindow *scrolled_window
       GtkStateFlags state;
       GtkBorder padding, border;
 
-      state = gtk_widget_get_state_flags (widget);
+      state = gtk_style_context_get_state (context);
 
       gtk_style_context_get_padding (context, state, &padding);
       gtk_style_context_get_border (context, state, &border);
@@ -2409,7 +2409,7 @@ gtk_scrolled_window_draw (GtkWidget *widget,
           GtkStateFlags state;
           GtkBorder padding, border;
 
-          state = gtk_widget_get_state_flags (widget);
+          state = gtk_style_context_get_state (context);
           gtk_style_context_get_padding (context, state, &padding);
           gtk_style_context_get_border (context, state, &border);
 
@@ -2635,7 +2635,7 @@ gtk_scrolled_window_relative_allocation (GtkWidget     *widget,
       GtkBorder padding, border;
 
       context = gtk_widget_get_style_context (widget);
-      state = gtk_widget_get_state_flags (widget);
+      state = gtk_style_context_get_state (context);
 
       gtk_style_context_get_border (context, state, &border);
       gtk_style_context_get_padding (context, state, &padding);
@@ -2759,7 +2759,7 @@ gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
   gtk_widget_get_preferred_width (priv->vscrollbar, &sb_width, NULL);
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
   gtk_style_context_get_padding (context, state, &padding);
@@ -3882,7 +3882,7 @@ gtk_scrolled_window_get_preferred_size (GtkWidget      *widget,
       GtkBorder padding, border;
 
       context = gtk_widget_get_style_context (GTK_WIDGET (widget));
-      state = gtk_widget_get_state_flags (GTK_WIDGET (widget));
+      state = gtk_style_context_get_state (context);
 
       gtk_style_context_get_padding (context, state, &padding);
       gtk_style_context_get_border (context, state, &border);
index 27dadd5bd7eb74c68bca6c23db5419478abdd4cb..f880c233d7a113d94c36da94f4f2442cda87f437 100644 (file)
@@ -262,7 +262,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView        *text_view,
   GtkStateFlags state;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (text_view));
+  state = gtk_style_context_get_state (context);
 
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   gtk_style_context_get_background_color (context, state, &bg_color);
index 2fca66647804858f354ca13d76f2ef7b615c91c1..eb43db5f91ffeaeef57e57b9e321ac543c84d1ac 100644 (file)
@@ -7821,7 +7821,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView        *text_view,
   GtkStateFlags state;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (text_view));
+  state = gtk_style_context_get_state (context);
 
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   gtk_style_context_get_background_color (context, state, &bg_color);
index 93a1e9ed5a9f7f68a7258c5e7fdb5ce43fa4251c..c5192000dd26e58eb33775adc1e4484b4490d540 100644 (file)
@@ -370,7 +370,7 @@ viewport_get_view_allocation (GtkViewport   *viewport,
   view_allocation->y = 0;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+  state = gtk_style_context_get_state (context);
 
   gtk_style_context_get_padding (context, state, &padding);
   gtk_style_context_get_border (context, state, &border);
index 78cfd5e00290a7f67968cf25d73f5bf5ec9c682e..ab316809391bb80b99e3a9fb57c50a64dc5e8697 100644 (file)
@@ -10400,7 +10400,7 @@ update_pango_context (GtkWidget    *widget,
 
   style_context = _gtk_widget_get_style_context (widget);
   gtk_style_context_get (style_context,
-                         _gtk_widget_get_state_flags (widget),
+                         gtk_style_context_get_state (style_context),
                          "font", &font_desc,
                          NULL);